# $Id: PKGBUILD 182418 2013-04-10 13:31:47Z stephane $
# Maintainer: Stéphane Gaudreault <stephane@archlinux.org>
# Contributor: Sebastien Binet <binet@farnsworth>
pkgbase=python-distribute
pkgname=('python-distribute' 'python2-distribute')
pkgver=0.6.36
pkgrel=1
pkgdesc="Easily build and distribute Python packages"
arch=('any')
license=('PSF')
url="http://pypi.python.org/pypi/distribute"
makedepends=('python' 'python2')
source=(http://pypi.python.org/packages/source/d/distribute/distribute-${pkgver}.tar.gz
        distribute-python2_and_3.patch)
sha1sums=('ab69711e4ea85c84d6710ecadf1d77427539f702'
          '420bc5d35e1dbfff8015f12e1a13d46973e34c68')
build() {
   cd "${srcdir}"

   pushd distribute-${pkgver}
   patch -Np1 -i ../distribute-python2_and_3.patch
   popd

   cp -a distribute-${pkgver}{,-python2}

   # Build python 3 module
   cd distribute-${pkgver}

   sed -i -e "s|^#\!.*/usr/bin/python|#!/usr/bin/python3|" setuptools/tests/test_resources.py

   python3 setup.py build

   # Build python 2 module
   cd ../distribute-${pkgver}-python2

   sed -i -e "s|^#\!.*/usr/bin/python|#!/usr/bin/python2|" setuptools/tests/test_resources.py

   python2 setup.py build
}

package_python-distribute() {
   depends=('python>=3.3')

   cd "${srcdir}/distribute-${pkgver}"
   python3 setup.py install --prefix=/usr --root="${pkgdir}" --optimize=1 --skip-build
}

package_python2-distribute() {
   depends=('python2>=2.7')
   provides=('setuptools')
   conflicts=('setuptools')

   cd "${srcdir}/distribute-${pkgver}-python2"
   python2 setup.py install --prefix=/usr --root="${pkgdir}" --optimize=1 --skip-build
}
